package command

import (
	"codejy/globalfunc"
	"codejy/structdef"
	"flag"
)

type MainFileCmd struct {
	mainFilePath string //主文件路径
	priority     int    //优先级
}

func init() {
	RegisterCommand(&MainFileCmd{
		priority: 0,
	})
}

// 绑定
func (m *MainFileCmd) Bind() {
	flag.StringVar(&m.mainFilePath, m.GetName(), "", m.GetDesc())
}

// 满足条件才执行命令
func (m *MainFileCmd) Condition() bool {
	return m.mainFilePath != ""
}

// 执行命令
func (m *MainFileCmd) Execute(threadStore *structdef.ThreadStore) {
	globalfunc.ExecuteFunc("CodejyRun", m.mainFilePath, true)

}

// 获取命令名称
func (m *MainFileCmd) GetName() string {
	return "f"
}

// 获取命令描述
func (m *MainFileCmd) GetDesc() string {
	return "设置主文件路径 ,比如: -f main.jy"
}

// 优先级  ,0最低...
func (m *MainFileCmd) GetPriority() int {
	return m.priority
}

// 是否终止
func (m *MainFileCmd) IsExit() bool {
	return true
}
